package export.monster
{
	import base.BaseMonster;
	
	import com.dusk.util.RandomUtil;
	
	import com.game.engine.MainGame;
	import com.game.event.GameEventType;
	
	import com.game.manager.AnimationManager;
	import com.game.manager.EventManager;
	
	import export.bullet.RegionBullet;
	import export.level.StageListener21;
	
	import flash.events.Event;
	
	import flash.geom.Rectangle;
	//蝙蝠石像
	public class Monster205 extends BaseMonster
	{
		public function Monster205()
		{
			super();
			setStatic();
		}
		
		override protected function initAttribute():void
		{
			super.initAttribute();
			mavo.attackRange = 150;
			if(MainGame.getIns().levelData.levelID == "2_1")
			{
				if(gc.pWorld.getBaseLevelListener() as StageListener21 != null)
				{
					if((gc.pWorld.getBaseLevelListener() as StageListener21)["hurtTimes"] > 5)
					{
						mavo.hpMax *= 2;
						setFullHp();
					}
				}
			}
		}
		
		override protected function myIntelligence():void
		{
			steelBodyCount = 999;
			super.myIntelligence();
		}
		
		override public function setAction(action:String):void
		{
			if(action == "dead")
			{
				MainGame.getIns().showDoor();
			}
			super.setAction(action);
		}
		
		override protected function initBBDC():void
		{
			bbdc = AnimationManager.getAnimation("Monster205Action");
			bbdc.setAction("idle");
			bbdc.turnRight();
			bbdc.addCallBack(onEnterFrame, onActionOver);
			bodyContainer.addChild(bbdc);
		}
		
		override protected function initCollideArea():void
		{
			collideBox = new Rectangle(-81,-207,163,210);
			super.initCollideArea();
		}
		
		override protected function onEnterFrame(action:String, frameCount:int):void
		{
			switch (action)
			{
				case "attack1":
					if(frameCount == 1)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setCollideArea(-81,-207,163 * bbdc.getDirect(),210);
						b.setHurt(getActionHurt("attack1"));
						b.setDestroyInCount(bbdc.frameLeft);
						b.setAction("Monster205Attack1");
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
			}
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return true;
		}
		
		override protected function releSkill1():void
		{
			for (var i:int = 0; i < 3; i++)
			{
				EventManager.getIns().dispatchEvent(GameEventType.CREATE_MONSTER,
						{type:RandomUtil.randSwitch([201,204]),
							x:RandomUtil.randInt(x - 200,x + 200),
							y:RandomUtil.randInt(y - 200,y)});
			}
		}
		
		override public function isWalkOrRun():Boolean
		{
			return false;
		}
	}
}